//
//  SecondScrollCellone.m
//  DesighBook
//
//  Created by 梅明 on 15/9/17.
//  Copyright (c) 2015年 梅明. All rights reserved.
//

#import "SecondScrollCellone.h"
#import "DesighModel.h"
#import "UIImageView+AFNetworking.h"
#import "AuthorDetail.h"
#define viewwith self.frame.size.width

@implementation SecondScrollCellone

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(CGFloat)createCell:(AuthorDetail *)model Anddetailabel:(UILabel *)_detailLabel
{
    UIImageView *whiteImg = [[UIImageView alloc]initWithFrame:CGRectMake(viewwith/2-30, -30, 60, 60)];
    whiteImg.backgroundColor = [UIColor whiteColor];
    whiteImg.layer.cornerRadius = 30;
    [self addSubview:whiteImg];
    [self bringSubviewToFront:whiteImg];
    
    UIImageView *faceimg = [[UIImageView alloc]initWithFrame:CGRectMake(viewwith/2-28, -28, 56, 56)];
    [faceimg setImageWithURL:[NSURL URLWithString:model.facepic]];
        faceimg.layer.cornerRadius = 27;
    faceimg.clipsToBounds = YES;
    [self addSubview:faceimg];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(viewwith/2-40, 28, 80, 30)];
    label1.text = model.authorname;
    label1.textAlignment = NSTextAlignmentCenter;
    label1.textColor = [UIColor lightGrayColor];
    [self addSubview:label1];
    
    UIView *horview = [[UIView alloc]initWithFrame:CGRectMake(viewwith/2-100, 58, 200, 0.3)];
    horview.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:horview];
    
    _detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 65, 0, 0)];
    [_detailLabel setNumberOfLines:0];
    _detailLabel.lineBreakMode = NSLineBreakByWordWrapping;//换行方式
    NSString *strTest = model.detailcontent;
    UIFont *font = [UIFont fontWithName:nil size:16];
    _detailLabel.font = font;
    _detailLabel.textAlignment = NSTextAlignmentLeft;
    CGSize size = CGSizeMake(viewwith,CGFLOAT_MAX);//LableWight标签宽度，固定的
    //计算实际frame大小，并将label的frame变成实际大小
    CGSize labelsize = [strTest sizeWithFont:font constrainedToSize:size lineBreakMode:_detailLabel.lineBreakMode];
    _detailLabel.frame = CGRectMake(0,70,labelsize.width, labelsize.height);
    _detailLabel.text = strTest;
    _detailLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:_detailLabel];

    return _detailLabel.frame.size.height;
}
@end
